<template>
  <div class="app-container">
    <uc-table url="admin/host/getInHostPage" name="主机信息" ref="hostTable" pageable table-border :search-form="searchForm">
      <template slot="searchForm">
      </template>
      <template slot="columns">
        <el-table-column prop="name" label="主机名称:" align="left"  show-overflow-tooltip></el-table-column>
        <el-table-column prop="enterpriseName" label="企业名称" align="left"  show-overflow-tooltip></el-table-column>
<!--        <el-table-column prop="hostId" label="" align="left"  show-overflow-tooltip></el-table-column>-->
        <el-table-column prop="type" label="主机类型" align="left" show-overflow-tooltip></el-table-column>
        <el-table-column prop="factory" label="厂家" align="left" show-overflow-tooltip></el-table-column>
        <el-table-column prop="address" label="操作" width="240" align="left" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <!--编辑按钮-->
            <el-button size="mini" icon="el-icon-edit" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
            <el-button size="mini" icon="el-icon-info" type="success" @click="handleInfo(scope.row)">详情</el-button>
            <el-button size="mini" type="danger" icon="el-icon-delete" :loading="deleteLoading" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </template>
    </uc-table>
  </div>
</template>

<script>
import UcTable from "@/components/UcTable/index.vue";
import {deleteInHost} from "../../../api/host";
export default {
  name: "list",
  components: {UcTable},
  data(){
    return{
      searchForm:{

      },

    }
  },
  computed:{

  },
  methods:{
    handleSearch(){
      this.$refs.hostTable.getTableData(1)
    },
    handleAdd(){
      this.$router.push("/enterprise/host/edit")
    },
    handleEdit(val){
      this.$router.push("/enterprise/host/edit?id="+val.id)
    },
    handleInfo(val){
      this.$router.push("/enterprise/host/info?id="+val.id)
    },
    handleDelete(val){
      this.$confirm('您确定要执行删除'+val.name+'这个主机吗？', '提醒信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteLoading = true
        deleteInHost(val).then(res=>{
          this.deleteLoading = false
          this.$notify.success({
            title: '成功',
            message: "删除主机信息成功"
          })
          this.handleSearch()
        }).catch(res=>{
          this.deleteLoading = false
          this.$notify.error({
            title: '失败',
            message: res.msg
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },

  }
}
</script>

<style scoped>

</style>